<template class="my_div">
  <div>
 
   <img :src="imgUrl" alt="">
   <P :style="{backgroundColor:color}" @click="changeColor">这是一直可爱的狗狗</P>
   <img src="https://scpic.chinaz.net/files/pic/pic9/202003/zzpic23514.jpg" alt="">
   <P>这是一直可爱的狗狗</P>
  </div>
</template>

<script>
export default {
data(){
  return{
    imgUrl:'https://scpic.chinaz.net/files/pic/pic9/202003/zzpic23514.jpg',
    color:''
  }
},
methods:{
  changeColor(){
this.color=`rgb(${Math.floor(Math.random()*256)},
${Math.floor(Math.random()*256)},
${Math.floor(Math.random()*256)})`
  }
}
}
</script>

<style>
.my_div {
  width: 200px;
  border: 1px solid black;
  text-align: center;
  float: left;
}

.my_div img {
  width: 100%;
  height: 200px;
}
</style>